package com.chb.system.controller.apis;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chb.system.annotation.OperLogAnnotation;
import com.chb.system.service.DictTypeService;
import com.chb.system.vo.DictTypeVo;
import com.hos.entity.sys.DictType;
import com.hos.entity.sys.Role;
import com.hos.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ：张家琪
 * @date ：Created in 2023/12/15 10:32
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("system/api/dictType")
@Api(value = "字典类型相关接口", tags = "字典类型相关接口")
public class APIDictTypeController {
    @Autowired
    private DictTypeService dictTypeService;

    @GetMapping("selectAllDictType")
    @ApiOperation(value = "获取所有可用字典类型的信息")
    public Result<List<DictType>> selectAllDictType() {
        return new Result<>(200, "查询成功", dictTypeService.selectAllDictType());
    }

    @PostMapping("findDictTypeByCond")
    @ApiOperation(value = "条件查询字典类型信息")
    public Result<Page<DictType>> findDictTypeByCond(@RequestBody DictTypeVo dictTypeVo) {
        return new Result<>(200, "查询成功", dictTypeService.findDictTypeByCond(dictTypeVo));
    }


    @DeleteMapping("deleteDictTypeByDictTypeIds/{ids}")
    @ApiOperation(value = "根据字典ID永久删除字典类型信息")
    @OperLogAnnotation(business_type = "系统业务-删除字典信息", operator_type = 1)
    public Result<Integer> deleteDictTypeByDictTypeIds(@PathVariable List<Long> ids) {
        return new Result<>(200, "删除成功", dictTypeService.deleteDiceTypeByIds(ids));
    }

    @PostMapping("updateDictType")
    @ApiOperation(value = "修改字典类型信息")
    @OperLogAnnotation(business_type = "系统业务-修改字典信息", operator_type = 1)
    public Result updateDictType(@RequestBody DictType dictType) {
        return new Result<>(200, "修改成功", dictTypeService.updateDict(dictType));
    }

    @PostMapping("/getDictTypeByDictTypeId/{dictTypeId}")
    @ApiOperation(value = "根据字典Id查询到一个字典类型信息")
    public Result<DictType> getDictTypeByDictTypeId(@PathVariable Long dictTypeId) {
        return new Result<DictType>(200, "查询成功", dictTypeService.getDictTypeById(dictTypeId));
    }

    @PostMapping("/addDictType")
    @ApiOperation(value = "添加字典类型信息")
    @OperLogAnnotation(business_type = "系统业务-增加字典信息", operator_type = 1)
    public Result<Integer> addDictType(DictType dictType) {
        return new Result<>(200, "添加成功", dictTypeService.addDictType(dictType));
    }
}